// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Runtime.Serialization;
using Elastic.Transport;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Migration
{
	[JsonConverter(typeof(DeprecationLevelConverter))]
	public enum DeprecationLevel
	{
		[EnumMember(Value = "warning")]
		Warning,
		[EnumMember(Value = "none")]
		None,
		[EnumMember(Value = "info")]
		Info,
		[EnumMember(Value = "critical")]
		Critical
	}

	internal sealed class DeprecationLevelConverter : JsonConverter<DeprecationLevel>
	{
		public override DeprecationLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "warning":
					return DeprecationLevel.Warning;
				case "none":
					return DeprecationLevel.None;
				case "info":
					return DeprecationLevel.Info;
				case "critical":
					return DeprecationLevel.Critical;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, DeprecationLevel value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case DeprecationLevel.Warning:
					writer.WriteStringValue("warning");
					return;
				case DeprecationLevel.None:
					writer.WriteStringValue("none");
					return;
				case DeprecationLevel.Info:
					writer.WriteStringValue("info");
					return;
				case DeprecationLevel.Critical:
					writer.WriteStringValue("critical");
					return;
			}

			writer.WriteNullValue();
		}
	}

	[JsonConverter(typeof(MigrationStatusConverter))]
	public enum MigrationStatus
	{
		[EnumMember(Value = "NO_MIGRATION_NEEDED")]
		NoMigrationNeeded,
		[EnumMember(Value = "MIGRATION_NEEDED")]
		MigrationNeeded,
		[EnumMember(Value = "IN_PROGRESS")]
		InProgress,
		[EnumMember(Value = "ERROR")]
		Error
	}

	internal sealed class MigrationStatusConverter : JsonConverter<MigrationStatus>
	{
		public override MigrationStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			var enumString = reader.GetString();
			switch (enumString)
			{
				case "NO_MIGRATION_NEEDED":
					return MigrationStatus.NoMigrationNeeded;
				case "MIGRATION_NEEDED":
					return MigrationStatus.MigrationNeeded;
				case "IN_PROGRESS":
					return MigrationStatus.InProgress;
				case "ERROR":
					return MigrationStatus.Error;
			}

			ThrowHelper.ThrowJsonException();
			return default;
		}

		public override void Write(Utf8JsonWriter writer, MigrationStatus value, JsonSerializerOptions options)
		{
			switch (value)
			{
				case MigrationStatus.NoMigrationNeeded:
					writer.WriteStringValue("NO_MIGRATION_NEEDED");
					return;
				case MigrationStatus.MigrationNeeded:
					writer.WriteStringValue("MIGRATION_NEEDED");
					return;
				case MigrationStatus.InProgress:
					writer.WriteStringValue("IN_PROGRESS");
					return;
				case MigrationStatus.Error:
					writer.WriteStringValue("ERROR");
					return;
			}

			writer.WriteNullValue();
		}
	}
}